/**
 * output package name
 */
package com.kingdee.eas.custom.hr.assessment.base.client;

import java.awt.event.*;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.bos.ctrl.kdf.fd2.gui.util.MsgBox;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.eas.framework.*;

/**
 * output class name
 */
public class AssessmentPeriodGuidanceEditUI extends AbstractAssessmentPeriodGuidanceEditUI
{
    private static final Logger logger = CoreUIObject.getLogger(AssessmentPeriodGuidanceEditUI.class);
    
    /**
     * output class constructor
     */
    public AssessmentPeriodGuidanceEditUI() throws Exception
    {
        super();
        this.txtYear.setText(String.valueOf(Calendar.getInstance().get(Calendar.YEAR)));
        for (int i = 1; i <= 12; i++) {
        	this.comboStartMonth.addItem(i);
        	this.comboEndMonth.addItem(i);
        }
    }

    /**
     * output storeFields method
     */
    public void storeFields()
    {
        super.storeFields();
    }

    /**
     * output btnYes_actionPerformed method
     */
    protected void btnYes_actionPerformed(java.awt.event.ActionEvent e) throws Exception
    {
        super.btnYes_actionPerformed(e);
        if (!String.valueOf(this.txtYear.getNumberValue()).matches("[1-9]\\d{3}")) {
        	MsgBox.show("year is 4 figures");
        } else if (Integer.parseInt(comboStartMonth.getSelectedItem().toString()) > Integer.parseInt(comboEndMonth.getSelectedItem().toString())) {
        	MsgBox.show("start date should be no more than the end date");
        }
        this.dataObjects.put("SUBMITTED", "true");
        disposeUIWindow();
    }

    /**
     * output btnNo_actionPerformed method
     */
    protected void btnNo_actionPerformed(java.awt.event.ActionEvent e) throws Exception
    {
        super.btnNo_actionPerformed(e);
        this.dataObjects.put("SUBMITTED", "false");
        disposeUIWindow();
    }

    public Map<String, Object> getData() {
    	if ("true".equals(this.dataObjects.get("SUBMITTED"))) {
    		return new HashMap<String, Object>() {
    			{
    				this.put("year", txtYear.getNumberValue());
    				this.put("startMonth", comboStartMonth.getSelectedItem());
    				this.put("endMonth", comboEndMonth.getSelectedItem());
    				this.put("autoGen", chkboxAutoGen.isSelected());
    			}
    		};    		
    	} else {
    		return null;
    	}
    }
}